package com.ant.collect.controller;


import com.ant.collect.common.ResultVo;
import com.ant.collect.dto.CompanyChangeInfoDto;
import com.ant.collect.handler.AntException;
import com.ant.collect.pojo.CompanyChangeInfo;
import com.ant.collect.service.ICompanyChangeInfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hzd
 * @since 2025-11-09
 */
@Api(tags = "公司信息变更申请接口")
@RestController
@RequestMapping("/companyChangeInfo")
public class CompanyChangeInfoController {

    @Autowired
    ICompanyChangeInfoService changeInfoService;

    /**
     * 分页查询用户数据
     *
     * @param
     * @return
     */
    @GetMapping("/queryCompanyList")
    public ResultVo queryCompanyList(CompanyChangeInfoDto dto) {
        Map<String, Object> map = changeInfoService.queryCompanyList(dto);
        return ResultVo.success(map);
    }

    @ApiOperation(value = "保存企业变信息")
    @PostMapping("/save")
    public ResultVo save(@RequestBody CompanyChangeInfoDto info) {
        changeInfoService.save(info);
        return ResultVo.success();
    }

    @ApiOperation(value = "通过id获取详情")
    @GetMapping("/findCompanyChangeInfoById")
    public ResultVo findCompanyChangeInfoById(Integer id) {
        if(id==null){
            throw new AntException("请输入id");
        }
        CompanyChangeInfo info = changeInfoService.getOne(new QueryWrapper<CompanyChangeInfo>().eq("id", id));
        return ResultVo.success("查询成功", info);
    }

    @ApiOperation(value = "审核通过变更信息")
    @GetMapping("/review")
    public ResultVo review(Integer id) {
        changeInfoService.review(id);
        return ResultVo.success("操作成功");
    }
}
